﻿using System;
using System.IO;

using Microsoft.Coding4Fun.TweetCraft.Twitter;

namespace Microsoft.Coding4Fun.TweetCraft.Tests
{
    public class FileDownloadClient : DownloadClient
    {
        /// <summary>
        /// Downloads a file from the given url to the destination path.
        /// </summary>
        /// <param name="url">The url of the file.</param>
        /// <param name="destinationPath">The destination path.</param>
        public override void DownloadFile(Uri url, string destinationPath)
        {
            if (url == null) 
                throw new ArgumentNullException("url");
            if (destinationPath == null) 
                throw new ArgumentNullException("destinationPath");
            if (!File.Exists(url.OriginalString))
                throw new ArgumentException("File does not exist.", "url");

            // Copy the source file to the destination path
            File.Copy(url.OriginalString, destinationPath, true);
        }
    }
}
